package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.system.domain.JyjcAuditList;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.JyjcSharingExpenses;
import com.ruoyi.system.service.IJyjcSharingExpensesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 费用分摊Controller
 * 
 * @author 石亚兵
 * @date 2025-07-09
 */
@RestController
@RequestMapping("/system/expenses")
public class JyjcSharingExpensesController extends BaseController
{
    @Autowired
    private IJyjcSharingExpensesService jyjcSharingExpensesService;

    /**
     * 查询费用分摊列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(JyjcSharingExpenses jyjcSharingExpenses)
    {
        startPage();
        List<JyjcSharingExpenses> list = jyjcSharingExpensesService.selectJyjcSharingExpensesList(jyjcSharingExpenses);
        return getDataTable(list);
    }

    /**
     * 导出费用分摊列表
     */
    @Anonymous
    @Log(title = "费用分摊", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JyjcSharingExpenses jyjcSharingExpenses)
    {
        List<JyjcSharingExpenses> list = jyjcSharingExpensesService.selectJyjcSharingExpensesList(jyjcSharingExpenses);
        ExcelUtil<JyjcSharingExpenses> util = new ExcelUtil<JyjcSharingExpenses>(JyjcSharingExpenses.class);
        util.exportExcel(response, list, "费用分摊数据");
    }

    /**
     * 获取费用分摊详细信息
     */
    @Anonymous
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(jyjcSharingExpensesService.selectJyjcSharingExpensesById(id));
    }

    /**
     * 新增费用分摊
     */
    @PreAuthorize("@ss.hasPermi('system:expenses:add')")
    @Log(title = "费用分摊", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JyjcSharingExpenses jyjcSharingExpenses)
    {
        return toAjax(jyjcSharingExpensesService.insertJyjcSharingExpenses(jyjcSharingExpenses));
    }

    /**
     * 修改费用分摊
     */
    @Anonymous
    @Log(title = "费用分摊", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JyjcSharingExpenses jyjcSharingExpenses)
    {
        return toAjax(jyjcSharingExpensesService.updateJyjcSharingExpenses(jyjcSharingExpenses));
    }

    /**
     * 删除费用分摊
     */
    @PreAuthorize("@ss.hasPermi('system:expenses:remove')")
    @Log(title = "费用分摊", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jyjcSharingExpensesService.deleteJyjcSharingExpensesByIds(ids));
    }
    @Anonymous
    @PostMapping("/generateData")
    public AjaxResult generateData(@RequestBody JyjcSharingExpenses jyjcSharingExpenses)
    {
        return toAjax(jyjcSharingExpensesService.generateData(jyjcSharingExpenses));
    }

    @Anonymous
    @PostMapping("/UpdateFlag")
    public AjaxResult UpdateFlag(@RequestBody JyjcSharingExpenses jyjcSharingExpenses)
    {
        return toAjax(jyjcSharingExpensesService.UpdateFlag(jyjcSharingExpenses));
    }
    @Anonymous
    @PostMapping("/UpdateFlagStatistics")
    public AjaxResult UpdateFlagStatistics(@RequestBody JyjcSharingExpenses jyjcSharingExpenses)
    {
        return toAjax(jyjcSharingExpensesService.UpdateFlagStatistics(jyjcSharingExpenses));
    }
}
